<html>
<head><title>登录</title>
    <meta charset="UTF-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
    <meta name="viewport" content="width=device-width, initial-scale=1"/>
    <link rel="stylesheet" href="/lib/bootstrap3/css/bootstrap.min.css"/>
    <link rel="SHORTCUT ICON" href="/images/index/bitbug_favicon.ico" type="image/x-icon">
    <link rel="stylesheet" href="/stylesheets/style.css"/>
    <script src="/lib/jquery-1.11.0.js"></script>
    <script src="/lib/bootstrap3/js/bootstrap.min.js"></script>
    <script src="/js/script.js"></script>
</head>
<body class="login-bg"></body>
<div class="login-con">
    <div class="ivu-card">
        <div class="ivu-card-head">欢迎登录</div>
        <div class="ivu-card-body">
            <div class="form-con">
                <form>
                    <div class="ivu-form-item">
                        <div class="ivu-form-item-content">
                            <div class="ivu-input-group">
                                <div class="ivu-input-group-prepend">
                                    <span>
                                        <i style="font-size: 12px;" class="glyphicon glyphicon-user">
                                        </i>
                                    </span>
                                </div>
                                <input id="loginname" name="loginname" type="text" placeholder="用户名" class="ivu-input"/>
                            </div>
                        </div>
                    </div>
                    <div class="ivu-form-item message-error">
                        <div class="ivu-form-item-content">
                            <div class="ivu-input-group">
                                <div class="ivu-input-group-prepend">
                                    <span>
                                        <i style="font-size: 12px;" class="glyphicon glyphicon-lock">
                                        </i>
                                    </span>
                                </div>
                                <input id="password" name="password" type="password" placeholder="密码"
                                       class="ivu-input"/></div>

                        </div>

                    </div>
                    <div class="ivu-form-item">
                        <button id="loginBtn" class="ivu-btn ivu-btn-primary ivu-btn-long">登录</button>
                    </div>
                </form>
                <p class="login-tip">请输入用户名和密码</p></div>
        </div>
    </div>
</div>
<script>
    $(function () {
        $('#loginBtn').click(function () {
            var loginname = $('#loginname').val();
            var password = $('#password').val();
            var html = '';
            html += '<div class="login-error-message"> ' + "请输入用户名或密码" + '</div>'
            if (!loginname || !password) {
                alert("请输入用户名和密码")
//                $('.message-error').append(html)
            } else {
                $.post('/loginHandler', {
                    loginname: loginname,
                    password: password
                }, function (result) {
                    if (result.errcode === 0) {
                        location.href = '/index';
                    } else {
                        alert(result.message)
                    }
                });
            }


        });
    });
</script>
</html>